package com.system.ras;

import java.security.interfaces.RSAPublicKey;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.codec.binary.Hex;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import common.base.web.BaseAction;


@Controller
public class RasController extends BaseAction {

	
	private final static Logger log= Logger.getLogger(RasController.class);
	
	@ResponseBody     
	@RequestMapping(value = "/getPairKey", method = RequestMethod.GET)     
	public Map<?,?> getKey() throws Exception {
		RSAPublicKey publicKey = MpbSecureRSAUtil.getDefaultPublicKey();
		Map<String, String> key = new HashMap<String,String>();
		key.put("modul",new String(Hex.encodeHex(publicKey.getModulus().toByteArray())));
		key.put("exponent",new String(Hex.encodeHex(publicKey.getPublicExponent().toByteArray())));
		log.info("********");
		return key;
	}
}